/**
 * 一些主程序要用到的方法.
 * @author: welling
 */
Weifox.main={
	/*
	 * 遍历User列表进行更新
	 */
	update:function(){
		var users=Weifox.data.users;
		var tls=null;
		var tl=null;//a timeline
		var now=new Date().getTime();
		var weifoxMain=Weifox.ui.weifoxMain;
		var time;//实际间隔
		var id;
		for(var i=0;i<users.length;i++){
			tls=users[i].timeline;
			id=users[i].app+users[i].user_id;
			for(var tln in tls){
				tl=tls[tln];
				if(tl.disabled)continue;
				time=(now-tl.lastUpdate);
				if(time>=tl.interval &&time >=60000){//时间大于设定的时间或大于1分钟更新
					
					try{
						tl.lastUpdate=now;
						weifoxMain.getTab(id+tln).update();
					}catch(e){
						//Weifox.log(id+tln);
					}
				}
			}
		}
	},
	/**
	 * 显示后,马上关闭,激活XBL
	 */
	activateXBL:function(){
		//激活Panels
		var panels=document.getElementById('weifox-panels').childNodes;
		for(var i=panels.length-1;i>-1;i--){
			panels[i].openPopupAtScreen(0,0);
			panels[i].hidePopup();
		}
		//激活其它.
		
	},

	showUserManager:function(){
		document.getElementById('weifox-usermanager-panel').openPopupAtScreen(400,33);
	},
	viewVersion:function(){
		var d=document;
		var p=d.getElementById('weifox-panel');
		var v=d.getElementById('weifox-version');
		if(p.state=='open'){
			p.hidePopup();
		}
		Weifox.ui.toggleMainPanel();
		v.openPopup(d.getElementById('weifox-title-logo'),'after_start');
		
	}
};
